﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>第三方支付流水</title>
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/demo.css">
    <link href="~/Content/Styles/Manage_Order.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
    <script src="~/Content/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>

    <script>
        $(function () {
            //initTable();
            acccertype();//初始化证件类型
            payflowtype();//初始化流水类型
            payname();//初始化支付渠道
            Dep();//组织结构
            dateboxSet();
        });

        //初始化表格 
        function initTable() {
            $('#load').datagrid({ 
                iconCls: 'icon-user', 
                loadMsg: '数据加载中...',
                nowrap: true,
                autoRowHeight: true,
                striped: true,
                url: '/FlowPay/getflowp',
                sortName: 'FlowPayID',
                sortOrder: 'asc',
                border: true,
                remoteSort: false,
                idField: 'FlowPayID',
                pageSize: 10,
                singleSelect: true,
                pagination: true,
                rownumbers: true,
                columns: [[
                    //{ field: 'ck', checkbox: true },
                    { field: 'FlowPayID', title: '流水编号', width: 100, sortable: true, align: 'center' },
                    { field: 'AccNum', title: '用户帐号', width: 250, sortable: true, align: 'center' },
                    { field: 'AccName', title: "用户姓名", width: 100, sortable: true, align: 'center', },
                    { field: 'PayFlowTypeName', title: "流水类型编号", width: 250, sortable: true, align: 'center' },
                    { field: 'PayName', title: "支付渠道", width: 150, sortable: true, align: 'center' },
                    {
                        field: 'PayHaveNub', title: '支付金额（元）', width: 150, sortable: true, align: 'center', formatter: function (val, rowdata, index) {
                            return val / 100;
                        }
                    },
                    { field: 'PayFlowTime', title: '发生时间', width: 150, sortable: true, align: 'center' },
                    { field: 'OperNum', title: '经办人', width: 150, sortable: true, align: 'center' },
                    { field: 'OrdrID', title: '订单编号', width: 80, sortable: true, align: 'center' },
                    { field: 'PayOherID', title: '第三方编号', width: 80, sortable: true, align: 'center' },
                    { field: 'PayBZ', title: '备注', width: 150, sortable: true, align: 'center' }
                ]],
                toolbar: '#tb'
            });
        }

        //证件类型
        function acccertype() {
            $.get("/FlowPay/getacccertype", {}, function (database) {
                $('#ZjType').combobox({
                    valueField: 'DictKey',
                    textField: 'DictName',
                    data: database
                });
            })
        }
        //流水类型
        function payflowtype() {
            
            $.get("/FlowPay/getpayflowtype", {}, function (database) {
                var a = {
                    "DictKey": "",
                    "DictName": "全部",
                }

                //database.push(a)
                database.splice(0, 0, a); // 将全部的选项放在最前
                $('#PayFlowType').combobox({
                    valueField: 'DictKey',
                    textField: 'DictName',
                    value: '',
                    text: '全部',
                    data: database
                })
            })
        }

        //支付渠道
        function payname() {
            
            $.get("/FlowPay/getpayname", {}, function (database) {
                var a = {
                    "PayID": "",
                    "PayName": "全部",
                }

                //database.push(a)
                database.splice(0, 0, a); // 将全部的选项放在最前
                $('#PayID').combobox({
                    valueField: 'PayID',
                    textField: 'PayName',
                    value: '',
                    text: '全部',
                    data: database
                })
            })
        }

        //组织结构
        function Dep() {
            $('#Zzjiegou').combotree({
                url: "/FlowPay/getdep",
                method: 'get',
                multiple: true,
            });
        }

        //设置日历表的选择范围
        function dateboxSet() {
            // 这是只允许选择今后10天之内的日期(修改后只能选择今天之前的时间)
            $('#PayFlowTime').datebox('calendar').calendar({
                validator: function (date) {
                    var now = new Date();
                    var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate());
                    //var d2 = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 10);
                    return d1 >= date;
                    //return d1 <= date && date <= d2;
                }
            });
            $('#EFlowTime').datebox('calendar').calendar({
                validator: function (date) {
                    var now = new Date();
                    var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate());
                    return d1 >= date;
                }
            });
        }

        //搜索
        function Search() {
            //获取页面查询数据
            var AccName = $('#AccName').textbox('getValue');
            var AccCall = $('#CallNumber').textbox('getValue');
            var AccID = $('#AccID').textbox('getValue');
            //var AccCerType = $('#ZjType').combobox('getValue');
            //var AccCerNub = $('#ZjNumber').textbox('getValue');
            var AccCerType = "";
            var AccCerNub = "";
            //var DepID = $('#Zzjiegou').combotree('getValue');
            var DepID = "";
            var PayFlowType = $('#PayFlowType').combobox('getValue');
            var PayID = $('#PayID').combobox('getValue');
            var PayFlowTime = $('#PayFlowTime').datebox('getValue');
            var EFlowTime = $('#EFlowTime').datebox('getValue');

            var sTime = $('#PayFlowTime').textbox('getValue').replace("-", "").replace("-", "");//开始日期
            var eTime = $('#EFlowTime').textbox('getValue').replace("-", "").replace("-", "");//结束日期
           
                if (sTime > eTime) {//开始日期不能大于结束日期
                    $.messager.alert("友情提示", "开始日期不能大于结束日期");
                }
                else if (AccName != "" || AccCall >= 0 || AccID != "" || AccCerType != "" || AccCerNub != "" || DepID != "" || PayFlowTime != "" || EFlowTime != "") {
                 //提交数据
                $('#load').datagrid({
                    iconCls: 'icon-user',
                    loadMsg: '数据加载中...',
                    nowrap: true,
                    autoRowHeight: true,
                    striped: true,
                    url: '/FlowPay/SearchPay?AccName=' + AccName + "&AccCall=" + AccCall + "&AccID=" + AccID + "&AccCerType=" + AccCerType + "&AccCerNub=" + AccCerNub + "&DepID=" + DepID + "&PayFlowType=" + PayFlowType + "&PayID=" + PayID + "&PayFlowTime=" + PayFlowTime+"&EFlowTime=" + EFlowTime,
                    sortName: 'FlowPayID',
                    sortOrder: 'asc',
                    border: true,
                    remoteSort: false,
                    idField: 'FlowPayID',
                    pageSize: 10,
                    singleSelect: true,
                    pagination: true,
                    rownumbers: true,
                    columns: [[
                        //{ field: 'ck', checkbox: true },
                        { field: 'FlowPayID', title: '流水编号', width: 100, sortable: true, align: 'center' },
                        { field: 'AccNum', title: '用户帐号', width: 250, sortable: true, align: 'center' },
                        { field: 'AccName', title: "用户姓名", width: 100, sortable: true, align: 'center', },
                        { field: 'PayFlowTypeName', title: "流水类型编号", width: 250, sortable: true, align: 'center' },
                        { field: 'PayName', title: "支付渠道", width: 150, sortable: true, align: 'center' },
                        {
                            field: 'PayHaveNub', title: '支付金额（元）', width: 150, sortable: true, align: 'center', formatter: function (val, rowdata, index) {
                                return val / 100;
                            }
                        },
                        { field: 'PayFlowTime', title: '发生时间', width: 150, sortable: true, align: 'center' },
                        { field: 'OperNum', title: '经办人', width: 150, sortable: true, align: 'center' },
                        { field: 'OrdrID', title: '订单编号', width: 80, sortable: true, align: 'center' },
                        { field: 'PayOherID', title: '第三方编号', width: 80, sortable: true, align: 'center' },
                        { field: 'PayBZ', title: '备注', width: 150, sortable: true, align: 'center' }
                    ]],
                    toolbar: '#tb'
                });
            }
            else {
                $.messager.alert("友情提示", "至少填写一个搜索条件");
            }
        }

        //清空文本框中的值
        function ClearText() {
        }

        //导出数据
        function Export() { 
            //var curTbl = document.getElementById("load"); 
            //alert(curTbl.rows.length);
            if (window.ActiveXObject) {
                alert("支持-通过ActiveXObject的一个新实例来创建XMLHttpRequest对象");
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            
            var ds = $('#load').datagrid("getRows");
           
            var AccName = $('#AccName').textbox('getValue');
            var AccCall = $('#CallNumber').textbox('getValue');
            var AccID = $('#AccID').textbox('getValue');
            //var AccCerType = $('#ZjType').combobox('getValue');
            //var AccCerNub = $('#ZjNumber').textbox('getValue');
            var AccCerType = "";
            var AccCerNub = "";
            //var DepID = $('#Zzjiegou').combotree('getValue');
            var DepID = "";
            var PayFlowType = $('#PayFlowType').combobox('getValue');
            var PayID = $('#PayID').combobox('getValue');
            var PayFlowTime = $('#PayFlowTime').datebox('getValue');
            var EFlowTime = $('#EFlowTime').datebox('getValue');
            if (AccName != "" || AccCall >= 0 || AccID != "" || AccCerType != "" || AccCerNub != "" || DepID != "" || PayFlowTime != "" || EFlowTime != "") {

                var data = {
                    AccName: AccName,
                    AccCall: AccCall,
                    AccID: AccID,
                    AccCerType: AccCerType,
                    AccCerNub: AccCerNub,
                    DepID: DepID,
                    PayFlowType: PayFlowType,
                    PayID: PayID,
                    PayFlowTime: PayFlowTime,
                    EFlowTime: EFlowTime,
                }
                $.post("/FlowPay/WriteExcel", data, function (database) {
                    if (database.msg = "1") {
                        alert(database.path);

                    }
                    else {

                        alert("系统错误！");
                    }
                })
            }
            
        }
        //结束excel进程，
        function Cleanup() {
            window.clearInterval(idTmr);
            CollectGarbage();
        }

    </script>

</head>
<body style="padding:0;">

    <!--表格加载S-->
    <div>
        <table id="load" style="width:auto;"></table>
    </div>
    <!--表格加载E-->

    <!--工具栏S-->
    <div id="tb" style="padding:5px;height:auto">
		<div style="margin-bottom:5px">
            查询条件：&nbsp;
            姓名：<input id="AccName" class="easyui-textbox" style="width:100px"/>&nbsp;
            手机号：<input id="CallNumber" class="easyui-textbox" style="width:100px"/>&nbsp;
            用户帐号：<input id="AccID" class="easyui-textbox" style="width:100px"/>&nbsp;
            @*证件类型：<input id="ZjType" class="easyui-combobox" style="width:100px"/>&nbsp;
            证件号：<input id="ZjNumber" class="easyui-textbox" style="width:100px"/>&nbsp;</br>*@
            @*组织结构：<input id="Zzjiegou" class="easyui-combotree" style="width:150px"/>&nbsp;*@
            流水类型：<input id="PayFlowType" class="easyui-combobox" style="width:100px"/>&nbsp;
            支付渠道：<input id="PayID" class="easyui-combobox" style="width:100px"/>&nbsp;
            时间：<input id="PayFlowTime" class="easyui-datebox" style="width:100px"/>&nbsp;
            至：<input id="EFlowTime" class="easyui-datebox" style="width:100px"/>&nbsp;
			<a href="#" class="easyui-linkbutton" onclick="Search()" iconCls="icon-search">查询</a> 
            <a href="#" class="easyui-linkbutton" onclick="Export()" iconCls="icon-search">导出</a> 
		</div>
	</div>
    <!--工具栏E-->
</body>
</html>
 